package com.qingcheng.controller;

import com.qingcheng.entity.PageResult;
import com.qingcheng.entity.Result;
import com.qingcheng.service.MemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("member")
public class MemberController {
    @Autowired
    private MemberService memberService;

    @GetMapping("memberAll")
    public Result memberAll(String loginName,String name,Integer page,Integer size){
        PageResult<Map> mapPageResult = this.memberService.MemberAll(loginName, name, page, size);
        return  new Result(200,"查询成功",mapPageResult);
    }

    @PostMapping("logicDelete")
    public Result logicDelete(Integer id){
        int i = this.memberService.logicDelete(id);
        return  new Result(200,"逻辑删除成功",i);
    }
    @PostMapping("insert")
    public Result insert(@RequestBody  Map map){
        this.memberService.insert(map);
        return new Result(200,"插入成功",map);
    }
    @PostMapping("updateStatus")
    public Result updateStatus(String STATUS,Integer id){
        int i = this.memberService.updateStatus(STATUS, id);
        return  new Result(200,"插入成功",i);
    }
    @GetMapping("selectbyid")
    public Result selecybyid(Integer id,Integer role_id,Integer arId){
        Map selecybyid = this.memberService.selecybyid(id, role_id,arId);
        return  new Result(200,"查询成功",selecybyid);
    }

    @PostMapping("update")
    public  Result update(@RequestBody Map map){
        this.memberService.update(map);
        return  new Result(200,"修改成功",1);
    }
    @PostMapping("deleteRole")
    public  Result deleteRole(Integer id){
        this.memberService.deleteRole(id);
        return  new Result(200,"删除成功",1);
    }

    @PostMapping("deleteIdRole")
    public Result deleteIdRole(Integer id){
        this.memberService.deleteIdRole(id);
        return  new Result(200,"删除成功",1);
    }
}
